# coding: utf-8
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QWidget, QVBoxLayout
from qfluentwidgets import HyperlinkCard, FluentIcon as FIF

from common import YEAR, AUTHOR, VERSION, HELP_URL, APP_NAME, UPDATE_URL, FEEDBACK_URL, FFMPEG_URL, SingleIcon


class AboutSettingWidget(QWidget):
    """ About setting widget. """

    def __init__(self, parent=None):
        super().__init__(parent)
        self.verticalLayout = QVBoxLayout(self)
        self.ffmpegCard = HyperlinkCard(
            FFMPEG_URL,
            self.tr('下载FFmpeg'),
            SingleIcon.FFMPEG,
            self.tr('FFmpeg下载'),
            '',
            self
        )

        self.helpCard = HyperlinkCard(
            HELP_URL,
            self.tr('打开帮助页面'),
            FIF.HELP,
            self.tr('帮助'),
            self.tr(f'发现关于 {APP_NAME} 的新特性并学习有用的技巧'),
            self
        )
        self.feedbackCard = HyperlinkCard(
            FEEDBACK_URL,
            self.tr('提供反馈'),
            FIF.FEEDBACK,
            self.tr('提供反馈'),
            self.tr(f'通过提供反馈帮助我们改进 {APP_NAME}'),
            self
        )
        self.aboutCard = HyperlinkCard(
            UPDATE_URL,
            self.tr('检查更新'),
            FIF.INFO,
            self.tr('关于'),
            '© ' + self.tr('版权') + f" {YEAR}, {AUTHOR}. " + self.tr('版本') + " " + VERSION,
            self
        )

        self.verticalLayout.setAlignment(Qt.AlignmentFlag.AlignTop)
        self.verticalLayout.addWidget(self.ffmpegCard)
        self.verticalLayout.addWidget(self.helpCard)
        self.verticalLayout.addWidget(self.feedbackCard)
        self.verticalLayout.addWidget(self.aboutCard)
